home *** CD-ROM | disk | FTP | other *** search
/ Singles Flirt Up Your Life! (German) / Singles Flirt Up Your Life.iso / data1.cab / Statemachine / doorOutdoor.lua < prev    next >
Text File  |  2004-01-29  |  2KB  |  87 lines

  1. -- door state machine
  2.  
  3. beginStateMachine()
  4.  
  5.     onEnter(function(msg)
  6.         setState("closed")
  7.     end )
  8.  
  9.     state("closed")
  10.         onEnter(function(msg)
  11.             setWalkability(0);
  12.         end )
  13.         
  14.         onMsg("openDoorLeft", function(msg)
  15.             setState("openLeft");
  16.         end )
  17.         
  18.         onMsg("openDoorRight", function(msg)
  19.             setState("openRight");
  20.         end )
  21.         
  22.         onMsg("buildMenu", function(msg)
  23.             -- build the pie menu
  24.             clearPieMenu();
  25.             local button ;
  26.             button = addPieMenuButton("pm_open", "openDoorLeft");
  27.             button.addDescription(USERACTION, "true");
  28.         end )
  29.     
  30.     state("openLeft")
  31.         
  32.         onEnter(function(msg)
  33.             startAnimation("doorOpenLeft");
  34.             setWalkability(1)
  35.             playSound("doorOpenClose");
  36.         end )
  37.         
  38.         onExit(function(msg)
  39.             startAnimation("doorCloseLeft");
  40.         end )
  41.         
  42.         onMsg("closeDoorLeft", function(msg)
  43.             setState("closed");
  44.         end )
  45.         
  46.         onMsg("closeDoorRight", function(msg)
  47.             setState("closed");
  48.         end )
  49.         
  50.         onMsg("buildMenu", function(msg)
  51.             -- build the pie menu
  52.             clearPieMenu();
  53.             local button ;
  54.             button = addPieMenuButton("pm_close", "closeDoorLeft");
  55.             button.addDescription(USERACTION, "true");
  56.         end )
  57.         
  58.     state("openRight")
  59.     
  60.         onEnter(function(msg)
  61.             startAnimation("doorOpenRight");
  62.             setWalkability(2)
  63.             playSound("doorOpenClose");
  64.         end )
  65.         
  66.         onExit(function(msg)
  67.             startAnimation("doorCloseRight");
  68.         end )
  69.         
  70.         onMsg("closeDoorLeft", function(msg)
  71.             setState("closed");
  72.         end )
  73.         
  74.         onMsg("closeDoorRight", function(msg)
  75.             setState("closed");
  76.         end )
  77.         
  78.         onMsg("buildMenu", function(msg)
  79.             -- build the pie menu
  80.             clearPieMenu();
  81.             local button ;
  82.             button = addPieMenuButton("pm_close", "closeDoorRight");
  83.             button.addDescription(USERACTION, "true");
  84.         end )
  85.     
  86. endStateMachine()
  87.